//
//  MessageViewController.m
//  DirectMember
//
//  Created by jzd on 2018/6/20.
//  Copyright © 2018年 宋佳. All rights reserved.
//

#import "MessageViewController.h"
#import "MessageCell.h"
#import "SendMessageVC.h"
#import "MessageDetailVC.h"

@interface MessageViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableV;

@end

@implementation MessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"留言";
    [self.tableV registerNib:[UINib nibWithNibName:NSStringFromClass([MessageCell class]) bundle:nil] forCellReuseIdentifier:MessageCellIdentifier];
    self.tableV.estimatedRowHeight = 80;
    self.tableV.rowHeight = UITableViewAutomaticDimension;
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"addMessage"] style:UIBarButtonItemStylePlain target:self action:@selector(addMesssageOnClick)];
    
}
-(void)addMesssageOnClick{
    SendMessageVC *vc = [[SendMessageVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:MessageCellIdentifier];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    MessageDetailVC *vc = [[MessageDetailVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
